package com.yungu.swift.schedule.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.order.service.OrderRiskControlService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import static com.yungu.swift.schedule.config.NacosListener.SYS_CONFIG;

/**
 * 订单相关定时器任务
 */
@Service
public class OrderMiddleWareService {

    @Reference
    private OrderRiskControlService orderRiskControlService;

    private static final Logger logger = LoggerFactory.getLogger(OrderMiddleWareService.class);

    /**
     * 增加异常处理机制：在2点（报表统计在3点执行，所以提前执行）进行统计时进行查询，把一直卡在新建订单状态的订单（订单状态为100并且存在超过30分钟），更新订单状态为已取消，记录为派单失败订单
     * 注意：因为拼车与当前其他业务的状态码还未同步，所以只处理出租车、快车、专车业务。
     */
    public void overTimeExceptionHandling() {
        logger.info("订单状态异常处理开始");
        ResponseData<String> responseData = orderRiskControlService.overTimeExceptionHandling(SYS_CONFIG.getAppid());
        logger.info(responseData.getMsg());
    }
}
